///PHILOTES Source Code.  (C)2012 PhiloLabs
#pragma once

#include "ExtrasPrerequisites.h "

#include "math/vector3.h"
#include "util/colourValue.h"
#include "OgreCommon.h"

namespace Extras {

	class _PhiloExtrasExport Billboard : public MemAlloc_SceneObj
    {
        friend class BillboardSet;
        friend class BillboardParticleRenderer;
    protected:
        bool mOwnDimensions;
        bool mUseTexcoordRect;
        uint16 mTexcoordIndex;      // index into the BillboardSet array of texture coordinates
        FloatRect mTexcoordRect;    // individual texture coordinates
        Real mWidth;
        Real mHeight;
    public:
        // Note the intentional public access to main internal variables used at runtime
        // Forcing access via get/set would be too costly for 000's of billboards
        Vector3 mPosition;
        // Normalised direction vector
        Vector3 mDirection;
        BillboardSet* mParentSet;
        ColourValue mColour;
        Radian mRotation;

        Billboard();

        ~Billboard();

        Billboard(const Vector3& position, BillboardSet* owner, const ColourValue& colour = ColourValue::White);

        const Radian& getRotation(void) const { return mRotation; }

        void setRotation(const Radian& rotation);

        void setPosition(const Vector3& position);

        void setPosition(Real x, Real y, Real z);

        const Vector3& getPosition(void) const;

        void setDimensions(Real width, Real height);

        void resetDimensions(void) { mOwnDimensions = false; }
        
        void setColour(const ColourValue& colour);

        const ColourValue& getColour(void) const;

        bool hasOwnDimensions(void) const;

        Real getOwnWidth(void) const;

        Real getOwnHeight(void) const;

        void _notifyOwner(BillboardSet* owner);

        bool isUseTexcoordRect(void) const { return mUseTexcoordRect; }

        void setTexcoordIndex(uint16 texcoordIndex);

        uint16 getTexcoordIndex(void) const { return mTexcoordIndex; }

        void setTexcoordRect(const FloatRect& texcoordRect);
        
        void setTexcoordRect(Real u0, Real v0, Real u1, Real v1);

        const FloatRect& getTexcoordRect(void) const { return mTexcoordRect; }
    };

	
}


